/* SPDX-License-Identifier: GPL-2.0+ */

#ifndef __BEEPER_H__
#define __BEEPER_H__

struct udevice;

/**
 * enum beeper_state_t - State used for beeper
 * - BEEPER_OFF - Beeper is not pressed
 * - BEEPER_ON - Beeper is pressed
 * - BEEPER_COUNT - Number of beeper state
 */
enum beeper_state_t {
	BEEPER_OFF = 0,
	BEEPER_ON = 1,
	BEEPER_TOGGLE = 2,
	BEEPER_COUNT,
};

/**
 * struct beeper_uc_plat - Platform data the uclass stores about each device
 *
 * @label:	beeper label
 */
struct beeper_uc_plat {
	const char *label;
	enum beeper_state_t default_state;
};

struct beeper_ops {
	/**
	 * set_state() - set the state of an LED
	 *
	 * @dev:	beeper device to change
	 * @state:	beeper state to set
	 * @return 0 if OK, -ve on error
	 */
	int (*set_state)(struct udevice *dev, enum beeper_state_t state);

	/**
	 * beeper_get_state() - get the state of an LED
	 *
	 * @dev:	LED device to change
	 * @return LED state led_state_t, or -ve on error
	 */
	enum beeper_state_t (*get_state)(struct udevice *dev);
};

#define beeper_get_ops(dev)	((struct beeper_ops *)(dev)->driver->ops)

/**
 * beeper_get_by_label() - Find an LED device by label
 *
 * @label:	LED label to look up
 * @devp:	Returns the associated device, if found
 * Return: 0 if found, -ENODEV if not found, other -ve on error
 */
int beeper_get_by_label(const char *label, struct udevice **devp);

/**
 * led_set_state() - set the state of an LED
 *
 * @dev:	LED device to change
 * @state:	LED state to set
 * Return: 0 if OK, -ve on error
 */
int beeper_set_state(struct udevice *dev, enum beeper_state_t state);

/**
 * led_get_state() - get the state of an LED
 *
 * @dev:	LED device to change
 * Return: LED state led_state_t, or -ve on error
 */
enum beeper_state_t beeper_get_state(struct udevice *dev);

#endif
